﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WEB.Services
{

    #region 所需枚举
    /// <summary>
    /// 文件上传类型
    /// </summary>
    public enum UpLoadType
    {
        /// <summary>
        /// 上传的资源
        /// </summary>
        Resource = 0,
        /// <summary>
        /// 普通文件
        /// </summary>
        FileUrl = 1,
        /// <summary>
        /// 图像文件
        /// </summary>
        Image = 2,
        /// <summary>
        /// 包的图像
        /// </summary>
        ItemImage = 3,
        /// <summary>
        /// 分类图标
        /// </summary>
        CategoryIcon = 4,
    }

    /// <summary>
    /// 上传错误信息列举
    /// </summary>
    public enum WarnEnum
    {
        ImgContentType,
        ImgContentLength,
        ImgExtension,
    }
    #endregion
    #region 文件上传基本服务类
    /// <summary>
    /// 文件上传基本服务类
    /// </summary>
    public abstract class FileUploadBase
    {

        /// <summary>
        /// 文件MIME
        /// </summary>
        protected static List<string> imgMIME = new List<string> 
        {  
            "application/x-zip-compressed",
            "application/octet-stream",
            "application/x-compressed",
            "application/x-rar-compressed",
            "application/zip",
            "application/vnd.ms-excel",
            "application/vnd.ms-powerpoint",
            "application/msword",
            "image/jpeg",
            "image/gif",
            "image/png",
            "audio/x-mpeg",
            "audio/x-wma",
            "application/x-shockwave-flash",
            "video/x-ms-wmv",
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "application/vnd.openxmlformats-officedocument.presentationml.presentation",
        };



        /// <summary>
        /// 验证消息字典
        /// </summary>
        protected static Dictionary<WarnEnum, string> msgDIC = new Dictionary<WarnEnum, string>
        {
              {WarnEnum.ImgContentType ,"只能上传指定类型的文件！" },
              {WarnEnum.ImgContentLength ,"只能上传文件大小为{0}以下！" },
              {WarnEnum.ImgExtension , "文件的扩展文件不正确"}
        };

        /// <summary>
        /// 相对地址字典
        /// </summary>
        public static Dictionary<UpLoadType, string> relativePathDic = new Dictionary<UpLoadType, string>
        {
            {UpLoadType.Resource ,@"Resource/" },
            {UpLoadType.FileUrl ,@"FileUpload/" },
            {UpLoadType.Image ,@"Image/" },
            {UpLoadType.ItemImage ,@"ItemImage/" },
           {UpLoadType.CategoryIcon ,@"CategoryIcon/" },
        };


        /// <summary>
        /// 图片后缀
        /// </summary>
        protected static string[] imgExtension = { "xls", "png", "doc", "zip", "rar", "ppt", "docx", "xlsx", "pptx", "mp3", "wma", "swf", "jpg", "jpeg", "gif" };


    }
    #endregion

}